<template>
    <div>
        <Head></Head>


        <div id="container">
            <div class="main">
                <div class="breadcrumb">
                    <a @click="goHome()" title="博客吧">首页</a> &raquo; 正文内容
                </div>

                <div class="post" id="post-8434" v-if="dat">
                    <h1 class="postTitle">{{dat.title}}</h1>


                    <div class="postmeta">
                        <span class="date">{{changeTime(dat.inputtime)}}</span>

                        <span class='tags'><a href="tag\zbupdate\index.html" rel="tag">{{changeTime(dat.updatetime)}}</a></span>
                        <span class="views">{{dat.click}} ℃</span>
                        <span class="cmt">0 条评论</span>
                    </div>


                    <div class="entry" v-html="dat.content">

                    </div>
                </div>

            </div>


            <!--右边导航栏-->

            <div class="sidebar">

                <Rank @change="changeId"></Rank>

                <Tag></Tag>

            </div>
        </div>

        <Foot></Foot>
    </div>
</template>

<script>
    import Tag from "../public/tag.vue"
    import Rank from "../public/rank.vue"
    import {CON} from "@/config/config.js"
    export default {
        name: "content",
        components: {
            Tag, Rank

        },
        data() {
            return {
                dat: [],
                id: ""
            }

        },
        watch:{

        },

        created() {
            document.body.scrollTop = 0;
            document.documentElement.scrollTop = 0;
            this.id = this.$route.query.id;

            this.getContent();
        },

        methods: {
            getContent(){

                this.$http({
                    url: this.$http.adornUrl(`article`),
                    method: 'get',
                    params: this.$http.adornParams({id:this.id})
                }).then(({data}) => {
                    console.log(data);
                });
            },
            /**
             *
             * */
            changeId(id){

                this.id = id;
                this.getContent();
            },

            /**
             * 回到首页
             * */
            goHome(){

                this.$router.push({path: '/'});
            },

            /**
             * 时间格式转换
             */
            changeTime(time) {

                return CON.changeTime(time);
            },

        }


    }
</script>

<style scoped>

</style>
